package com.algorithm.linesegment;/*
 *@Author:DOWN
 *@Date:2022/5/6 11:45
 *@Comment:
 */

public class Solution303_2 {
    private int[] sum;

    public void NumArray(int[] nums) {
        sum=new int[nums.length+1];
        sum[0]=0;
        for(int i=1;i<sum.length;i++){
            sum[i]=sum[i-1]+nums[i-1];
        }
    }

    public int sumRange(int left, int right) {
        return sum[right+1]-sum[left];
    }
}
